//
//  BaseViewController.m
//  statistiscData
//
//  Created by zhaochengfeng on 2016/12/21.
//  Copyright © 2016年 bmwl. All rights reserved.
//

#import "BaseViewController.h"
#import "PublicColor.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (self.navigationController.viewControllers.count > 1) {
        [self setLeftBarImage:@"left_arr"];
    }
    [self basicConfig];
}

- (void)basicConfig{
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.translucent = NO;
    self.extendedLayoutIncludesOpaqueBars = YES;
}

- (void)setLeftBarTitle:(NSString *)leftBarTitle {
    _leftBarTitle = leftBarTitle;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:leftBarTitle style:UIBarButtonItemStylePlain target:self action:@selector(leftItemClicked:)];
    [self.navigationItem.leftBarButtonItem setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} forState:UIControlStateNormal];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
}

- (void)setLeftBarImage:(NSString *)leftBarImage {
    _leftBarImage = leftBarImage;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:leftBarImage] style:UIBarButtonItemStylePlain target:self action:@selector(leftItemClicked:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
}

- (void)setRightBarTitle:(NSString *)rightBarTitle {
    _rightBarTitle = rightBarTitle;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:rightBarTitle style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClicked:)];
    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
}

- (void)setRightBarImage:(NSString *)rightBarImage {
    _rightBarImage = rightBarImage;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:rightBarImage] style:UIBarButtonItemStylePlain target:self action:@selector(rightItemClicked:)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
}

- (void)leftItemClicked: (UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)rightItemClicked: (UIBarButtonItem *)item {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
